<template>

  <div>
     <el-table
    :data="getcatelist"
    border
    style="width: 100%"
     row-key="id"
 :tree-props="{ children: 'children' }"
    >
    <el-table-column
      prop="pid"
      label="分类编号"
      width="180">
    </el-table-column>
    <el-table-column
      prop="catename"
      label="分类名称"
      width="180">
    </el-table-column>
   <el-table-column
      prop="img"
      label="图片"
      width="180">
       <template slot-scope="item">
        <img v-if="item.row.img" class="imgUrl" :src="item.row.img" alt="">
      </template>
    </el-table-column>
   <el-table-column

      label="状态">
 <el-button plain size="mini" type="danger">禁用</el-button>

    </el-table-column>
        <el-table-column label="操作">
         <template  slot-scope="item">
 <el-button plain  size="mini"  type="primary" @click='edit(item.row.id)'>编辑</el-button>
 <el-button plain size="mini" type="danger" @click="dit(item.row.id)">删除</el-button>
         </template>

    </el-table-column>

  </el-table>
  </div>
</template>

<script>
import { cateDelete } from '../../../api/api.js'
import { mapGetters, mapActions } from 'vuex'
export default {
  data () {
    return {

    }
  },
  mounted () {

  },
  computed: {
    ...mapGetters('classify', ['getcatelist'])
  },
  methods: {
    ...mapActions('classify', ['getCatelist']),
    dit (id) {
      this.$confirm('你确定要删除吗', '提示', {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning '

      }).then(() => {
        cateDelete({ id }).then(res => {
          if (res.code === 200) {
            this.$message.success(res.msg)
            this.getCatelist()
          }
        })
      })
    },
    edit (id) {
      this.$emit('edit', id)
    }
  }
}
</script>

<style scoped>
.imgUrl{
  width: 100px;
  height: 100%;
}

</style>
